package com.diqye.controller.wjdc;

import com.diqye.db.model.XModel;
import com.diqye.engine.DBController;
import com.diqye.engine.render.Error404Render;
import com.diqye.engine.render.JspRender;

public class Question extends DBController {

	public void view(){
		String id=getRequest().getParameter("id"),
				sql="select * from wjdc.question_tab where isdelete='0' and id=#{0}";
			//	sql2="select * from questionitem_tab where id =#{0}";
		XModel m1 = db.findFirst(sql, Integer.valueOf(id));
		if(m1==null){
			render(new Error404Render());
			return;
		}
		getRequest().setAttribute("m1", m1);
		render(new JspRender("/WEB-INF/jsp/wjdc/wjdc.jsp"));
	}
	
	public void quesition(){
		String sql="select * from wjdc.questionitem_tab where pid =#{0} and (lastanswer is null or lastanswer = #{1}) order by lastanser";
		int pid = getParams().getInt("id");
		renderOk(db.findFirst(sql, pid,getParams().get("answer")));
	}
}
